﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class BaseData_AddCollocationArticle : System.Web.UI.Page
{


    protected void Page_Load(object sender, EventArgs e)
    {
        Check.CheckPermission("200300112");
        if (!IsPostBack)
        {
            BindDropCollocationType();
        }
    }
    protected void Page_PreInit(object sender, EventArgs e)
    {
        Page.Theme = BLL.Common.GetWSMThemes();
    }
    private void BindDropCollocationType()
    {
        DataTable dtCollocationType = new BLL.DPCategory().GetAllDpCategory().Tables[0];
        dropCollocationType.DataSource = dtCollocationType;
        dropCollocationType.DataTextField = "DP_NAME";
        dropCollocationType.DataValueField = "DP_ID";
        dropCollocationType.DataBind();
    }

    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (!Check.CheckPermission("200300112", "00001"))
        {
            Share.Alert(Page, "无权操作"); return;
        }
        if (txtTitle.Text == "")
        {
            Share.Alert(this.Page,"请填写文章标题！"); return;
        }
        Model.CollocationArticle article = new Model.CollocationArticle();
        article.ArticleID = new BLL.CollocationArticle().GetNewArticleId();
        BLL.Common.ADDLSH("200300112");
        article.ArticleTypeId = dropCollocationType.SelectedValue;
        article.Title = txtTitle.Text;
        article.Content = WebEditor1.Text;
        article.CreateDate = DateTime.Now;

        if (new BLL.CollocationArticle().Add(article) == article.ArticleID)
        {
            Share.InsertLog("200300112", "00001");
            Response.Write("<script>alert('添加文章成功！');window.location.href='CollocationArticleMain.aspx'</script>");
        }
        else
        {
            Share.Alert(this.Page, "添加文章失败");
        }
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {

    }
}
